package com.taotao.rest.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.rest.dao.JedisClient;

@Service
public class RedisServiceImpl implements RedisService {

	@Autowired
	private JedisClient jedisClient;
	@Value("${INDEX_CONTENT_REDIS_KEY}")
	private String INDEX_CONTENT_REDIS_KEY;
	@Value("${INDEX_ITEMCAT_REDIS_KEY}")
	private String INDEX_ITEMCAT_REDIS_KEY;

	@Override
	public TaotaoResult sysncContent(long categoryId) {
		try {
			jedisClient.hdel(INDEX_CONTENT_REDIS_KEY, categoryId + "");
		} catch (Exception e) {
			return TaotaoResult.build(500, e.getMessage());
		}

		return TaotaoResult.ok();
	}

	@Override
	public TaotaoResult sysItem() {
		// TODO Auto-generated method stub
		try {
			jedisClient.hdel(INDEX_ITEMCAT_REDIS_KEY, 0L + "");
		} catch (Exception e) {
			return TaotaoResult.build(500, e.getMessage());
		}
		return TaotaoResult.ok();
	}

}
